#ifndef __ARCH_UM_INCLUDE_STUB_H__
#define __ARCH_UM_INCLUDE_STUB_H__

#include <types.h>

struct stub_frame {
	uint32_t eax;
	uint32_t ebx;
	uint32_t ecx;
	uint32_t edx;
	uint32_t esi;
	uint32_t edi;
	uint32_t data[10];
};

struct stub_stack {
	uintptr_t current_addr;
	uint32_t current_no;
	void* frames;
};

#define current_stub_frame(stack)						\
	((struct stub_frame *)&(stack->frames) + stack->current_no)

extern void* __syscall_stub_start;
extern void* __syscall_stub_end;

void stub_entry (void);
void stub_start (void);
void stub_segv_handler (int sig);
void stub_exec_syscall ();

void stub_push_frame (struct stub_stack* stack);
void stub_pop_frame (struct stub_stack* stack);

#endif  // __ARCH_UM_INCLUDE_STUB_H__
